<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script src="axios.min.js"></script>
    <script src="request.js"></script>
</head>
<body>
<h1>首页</h1>
<button onclick="logout()">登出</button>
<div>token => <span id="token">[[${token}]]</span></div>
<br/>
<br/>
<div th:each="menu:${menus}">
    <a th:if="${menu.parentId != 0}" th:href="${menu.url}+'?token='+${token}">[[${menu.menuName}]]</a>
</div>
</body>
<script>
    function logout(){
        const token = document.querySelector("#token").innerText

        let request = getAxios(axios, token)

        request({
            url: 'logout',
            method: 'get'
        }).then(res => {
            if (res.status === 200) {
                location.href = "http://localhost/login.html"
            }
        })
    }
</script>
</html>